stock find_itemplugin()
{
	for(new i = 0; i < get_pluginsnum(); ++i)
	{
		new temp[2], name[64]
		get_plugin(i, name, 63, temp, 1, temp, 1, temp, 1, temp, 1)
 		if(equali(name, "Upgrades.amxx")) {
 			return i
		}
	}
 	return -1
}

stock find_itemindex()
{
	new temp[2], name[64], pluginname[64]
	get_plugin(-1, pluginname, 63, temp, 1, temp, 1, temp, 1, temp, 1)
	for (new i = 0; i < get_pluginsnum(); ++i)
	{
		get_plugin(i, name, 63, temp, 1, temp, 1, temp, 1, temp, 1)
 		if(equal(name, pluginname)) {
 			return i
		}
	}
 	return -1
}

stock register_item(item_name[], item_desc[], item_cost)
{
	new item_index = find_itemindex()
	new itemplugin = find_itemplugin()
	new itemregfunc = get_func_id("register_item", itemplugin)

	new temp = callfunc_begin_i(itemregfunc, itemplugin)
	if(temp == -1 || temp == -2)
	{
		if(temp == -2) {
			log_amx("You have to many items, and need to increase the MAX_ITEMS define")
		} else {
			log_amx("A unkown error has happend, make sure the Upgrades plugin is loaded")
		}
		return PLUGIN_HANDLED		
	}

	callfunc_push_int(item_index)
	callfunc_push_str(item_name)
	callfunc_push_str(item_desc)
	callfunc_push_int(item_cost)
	
	temp = callfunc_end()
	if(temp == -1 || temp == -2) {
		return PLUGIN_HANDLED
	}
	return temp
}